import { consts } from "@/module-00-codebase/pkg-00-const";

const levelsMap = new Map<string, number>();
levelsMap.set("DEBUG", -1);
levelsMap.set("INFO", 0);
levelsMap.set("WARN", 1);
levelsMap.set("ERROR", 2);

export class ConsoleLog {
  public debug(msg: string): void {
    let level = levelsMap.get(consts.LOG_LEVEL) as number;
    let crnt = levelsMap.get("DEBUG") as number;
    if (level <= crnt) {
      console.log(msg);
    }
  }
  public info(msg: string): void {
    let level = levelsMap.get(consts.LOG_LEVEL) as number;
    let crnt = levelsMap.get("INFO") as number;
    if (level <= crnt) {
      console.info(msg);
    }
  }
  public warn(msg: string): void {
    let level = levelsMap.get(consts.LOG_LEVEL) as number;
    let crnt = levelsMap.get("WARN") as number;
    if (level <= crnt) {
      console.warn(msg);
    }
  }
  public error(msg: string): void {
    let level = levelsMap.get(consts.LOG_LEVEL) as number;
    let crnt = levelsMap.get("ERROR") as number;
    if (level <= crnt) {
      console.error(msg);
    }
  }
}

export const order = () => consts.firstOrder;
